-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added .not() matcher #81
Conversation
Codecov Report
@@ Coverage Diff @@
## master #81 +/- ##
==========================================
+ Coverage 94.27% 95.02% +0.75%
==========================================
Files 33 34 +1
Lines 576 623 +47
Branches 67 69 +2
==========================================
+ Hits 543 592 +49
+ Misses 24 22 -2
Partials 9 9
Continue to review full report at Codecov.
|
@cakeinpanic wow another PR :) I think that second version is more human readable |
246e120
to
494ebe5
Compare
@NagRock But it doesn't matter when we speak about how it will be used in the end) I've fixed everything, take a look please |
19bcd48
to
32bd8d8
Compare
@NagRock hello! can you take a look at PR? Any comments? |
README.md
Outdated
verify(mockedFoo.getBar(not().strictEqual(2))).once(); // was called with anything except 2 once | ||
verify(mockedFoo.getBar(between(2, 3))).thrice(); // was called with arg beween 2-3 exactly three times | ||
verify(mockedFoo.getBar(anyNumber()).times(4); // was called with any number arg exactly four times | ||
verify(mockedFoo.getBar(not().anyNumber).times(4); // was called with anything but not a number exactly four times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ()
on anyNumber
-> should be: not().anyNumber()
src/ts-mockito.ts
Outdated
@@ -114,14 +115,18 @@ export function strictEqual(expectedValue: any): Matcher { | |||
return new StrictEqualMatcher(expectedValue); | |||
} | |||
|
|||
export function match(expectedValue: RegExp | string): Matcher { | |||
return new MatchingStringMatcher(expectedValue); | |||
export function matchString(expectedValue: RegExp | string): Matcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version with match
name has been already released so we should not change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can add matchString
as duplicated function and add deprecation infromation to match
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets leave it as match
@@ -1,38 +1,45 @@ | |||
import {Matcher} from "../../../src/matcher/type/Matcher"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about new spec file for Not
matcher? Now spec descriptions are a little bit strange checking if class matches returns true
but in then
section we got expect(notResult).toBeFalsy();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a question!
by adding notResult check to every unit I wanted to notify every contributor that he should provide his matcher to Not, otherwise it won't work(
This is the _lack of architecture` I've mentioned before
maybe just rewrite texts in it
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it, yake a look please
@bendykowski take a look at this PR too please |
@cakeinpanic I'll try to check it today evening when I get home |
@cakeinpanic I've checked the PR and found out a bit cleaner implementation but didn't have time to finish it. I'll do it today afternoon. |
@bendykowski opened new PR extending this one #84 |
I've added
.not()
method for matchersThere are two options: one looks not so great as in jasmine, but still offers some opportunities:
Another one looks more alike, but I have some doubts about architecture
What do you think?